<!DOCTYPE html>
<html class="x-admin-sm">
{include file='public/header'}
<script src="/admin/xadmin/lib/layui/upload.js" charset="utf-8"></script>

<body>
    <div class="x-body">
        <form class="layui-form" lay-filter="formAjax">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>用户ID
                </label>
                <div class="layui-input-block">
                    <input type="text" name="id" id="id" placeholder="用户ID" required="required"
                        lay-verify="required" autocomplete="off" disabled class="layui-input" value="" />
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>赠送类型</label>
                <div class="layui-input-block">
                    <select name="type" id="type" lay-filter="type">
                        <option value="1">赠送K币</option>
                        <option value="2">赠送会员</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item" id="moneyBox" style="display: block;">
                <label class="layui-form-label">
                    K币数量
                </label>
                <div class="layui-input-block">
                    <input type="text" name="money" id="money" placeholder="请填写整数，一元等于100K币" autocomplete="off" class="layui-input" value="" />
                </div>
            </div>

            <div id="cooperation_time" style="display: none;">
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        会员有效期
                    </label>
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="expiration_time" id="time" autocomplete="off" placeholder="结束日期">
                        </div>
                    </div>
                </div>
            </div>

            <button id="submitData" class="layui-btn" lay-submit lay-filter="submitData" style="display: none;" />
        </form>
    </div>
    <script>
        let id = GetQueryString('id')
        let params = {
            editUrl: '/admin/user/givekCoins',
        }
        form_ajax(params)

        $('#id').val(GetQueryString('id'))

        layui.use(['laydate','form'], function(){
            var laydate = layui.laydate;
            laydate.render({
                elem: '#time',
                format: 'yyyy-MM-dd'
            });
            
            var form = layui.form;
            form.on('select(type)', function(data){
                if(data.value == 1){
                    $('#moneyBox').show()
                    $('#cooperation_time').hide()
                }else{
                    $('#moneyBox').hide()
                    $('#cooperation_time').show()
                }
            });
        })
    </script>
</body>

</html>